<?php
namespace Home\Controller;
use Think\Model;
use Think\Controller;
use Think\Verify;
use Think\Image;
use Think\Upload;
use Think\Page;
class ManagerController extends Controller {
    public function index(){
        $this->display('index');
    }
    public function page1(){
        $theuser=M('theuser');
        $value = session('username');
        $where['username']=$value;
        $sql=$theuser->where($where)->find();
        $str="";
        switch ($sql['sex'])
        {
            case 0:
                $str="男";
                break;
            case 1:
                $str="女";
                break;
        }
        $this->assign(sql,$sql);
        $this->assign(str,$str);
        $this->display('page1','utf-8');
    }

    //page2
    public function page2(){
        $teacher=M("teacher");
        $information=M('information');
        //$sql2=$select->where("a.idTwo = b.tclass")->table(array('information'=>'a','teacher'=>'b'))->select();
        $arr=$teacher->where("a.idTwo=b.tclass")->table(array('information'=>a,'teacher'=>b))->select();
        $count1=$teacher->where("a.idTwo=b.tclass")->table(array('information'=>a,'teacher'=>b))->count();

        $str=array();
        $str2=array();
        for ($i=0;$i<$count1;$i++)
        {
            if($arr[$i]['sced'])
            {
                $str2[$i]="第一学期";
            }else{
                $str2[$i]="第一学期";
            }
            if($arr[$i]['type']==0)
            {
                $str[$i]="公共基础平台课/数学课";
            }elseif ($arr[$i]['type']==2)
            {
                $str[$i]="公共基础平台课/英语课";
            }else{
                $str[$i]="学科专业课";
            }
        }
        $this->assign(arr,$arr);
        $this->assign(Nu,1);
        $this->assign(count1,$count1);
        $this->assign(str,$str);
        $this->assign(str2,$str2);
        $this->display('page2','utf-8');
    }


    //page3
    public function page3(){
        $teacher=M("teacher");
        $information=M('information');
        $sss=session('username');
        $arr=$teacher->where("a.idTwo=b.tclass AND b.id=$sss")->table(array('information'=>a,'teacher'=>b))->select();
        $count1=$teacher->where("a.idTwo=b.tclass AND b.id=$sss")->table(array('information'=>a,'teacher'=>b))->count();
        $this->assign(arr,$arr);
        $this->assign(Nu,1);
        $this->assign(count1,$count1);
        $b="";
        $a=array();
        for($i=0;$i<$count1;$i++)
        {
            $th=$arr[$i]['tclass'];
            $a[$i]=$arr[$i]['pro']==100?(($a[$i]=$arr[$i]['ispost']==0)?"<a href=\"score.html?id={$th}\">评分</a>":"<a href=\"../../Admin/Index/chengjixiugai.html?id={$th}\">修改成绩</a>"):"您当前并未完成所有课时";
        }

        $this->assign('num',1);
        $this->assign(a,$a);
        $this->display('page3','utf-8');
    }

    
    public function score() {
        $a= $_GET['id'];
        $select=M('select');
        $information=M('information');
        $count1=$select->field("a.iname")->where("a.idTwo=b.class AND b.class=$a")->table(array( 'information'=>a,'select'=>b))->count();
        $arr=$select->field("a.iname")->where("a.idTwo=b.class AND b.class=$a")->table(array('information'=>a,'select'=>b))->select();
        $theuser=M('theuser');
        //$count2=$select->field("a.name,a.sex,a.xueyuan,b.sid AND b.class=$a")->where("a.id=b.tname")->table(array('theuser'=>a,'select'=>b))->select();
        $arr2=$select->field("a.name,a.sex,a.xueyuan,b.sid,a.id")->where("a.id=b.tname AND b.class=$a")->table(array('theuser'=>a,'select'=>b))->select();
        $personal=M('personal');
        $str[]=array();
        $at[]=array();
        $menu[]=array();
        for($i=0;$i<$count1;$i++)
        {
            $str[$i]=($arr2[$i]['sex']==0?"男":"女");
            $at[$i]=$arr2[$i]['sid']==1?"重修":"初选";
        }
        $this->assign(menu,$menu);
        $this->assign('th',$a);
        $this->assign(arr2,$arr2);
        $this->assign(at,$at);
        $this->assign(str,$str);
        $this->assign(arr,$arr);
        $this->assign(count1,$count1);
        $this->display('score','utf-8');
    }
}